﻿package com.tudou.utils
{
    import flash.display.*;
    import flash.events.*;
    import flash.geom.*;

    public class FullScreen extends EventDispatcher
    {
        private var stage:Stage;
        private static var instace:FullScreen;

        public function FullScreen()
        {
            return;
        }// end function

        public function init(param1:Stage) : void
        {
            this.stage = param1;
            param1.addEventListener(FullScreenEvent.FULL_SCREEN, fullscreenHlr);
            return;
        }// end function

        private function fullscreenHlr(event:FullScreenEvent) : void
        {
            dispatchEvent(event.clone());
            return;
        }// end function

        public function setFullRect(param1:Rectangle) : void
        {
            if (stage.hasOwnProperty("fullScreenSourceRect"))
            {
                stage.fullScreenSourceRect = param1;
            }
            return;
        }// end function

        public function get isFullScreen() : Boolean
        {
            return stage.displayState == StageDisplayState.FULL_SCREEN;
        }// end function

        public function exitFullScreen() : void
        {
            try
            {
                if (isFullScreen)
                {
                    stage.displayState = StageDisplayState.NORMAL;
                }
            }
            catch (e:Error)
            {
                trace(e);
            }
            return;
        }// end function

        public function set isFullScreen(param1:Boolean) : void
        {
            var b:* = param1;
            try
            {
                stage.displayState = b ? (StageDisplayState.FULL_SCREEN) : (StageDisplayState.NORMAL);
            }
            catch (e:Error)
            {
                trace(e);
            }
            return;
        }// end function

        public static function getInst() : FullScreen
        {
            var _loc_1:* = instace || new FullScreen;
            instace = instace || new FullScreen;
            return _loc_1;
        }// end function

    }
}
